<template>
  <div class="app-container">
    <el-table :data="merchantList">
      <el-table-column prop="task.processDefinitionId" label="id"></el-table-column>
      <el-table-column prop="task.processInstanceId" label="processInstanceId"></el-table-column>
      <el-table-column prop="task.name" label="name"></el-table-column>
      <el-table-column prop="task.id" label="taskId"></el-table-column>
      <el-table-column prop="historicProcessInstance.startTime" label="时间"></el-table-column>
      <el-table-column prop="task.assignee" label="用户名称"></el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            v-hasPermi="['merchant:merchant:complete']"
            @click="handleUpdate(scope.row)"
          >审核</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 添加或修改商户对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="审核" prop="auditFlag">
          <el-select v-model="form.auditFlag" placeholder="审核">
            <el-option label="同意" value="true"></el-option>
            <el-option label="驳回" value="false"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="请输入意见" prop="message">
          <el-input v-model="form.message" placeholder="请输入意见" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="complete">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listMerchant, getMerchant, delMerchant, addMerchant, updateMerchant,query,complete } from "@/api/merchant/merchant";

export default {
  name: "Check",
  data() {
    return {
      merchantList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询商户列表 */
    getList() {
      this.loading = true;
        query().then(response => {
        console.log(response.data)
        this.merchantList = response.data
      });
    },
    complete() {
      complete(this.form).then(response => {
          this.$message.success("审核完成")
        this.getList()
      });
    },
    /** 提交按钮 */
    handleUpdate(row) {
      this.open = true;
      this.form.taskId=row.task.id
    }
  }
};
</script>
